package com.ljc.config;

import com.ljc.common.lang.Consts;

import org.modelmapper.ModelMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @Author: ljc
 * @Date:Created in 13:11 2022/2/8
 */
@Configuration
public class MvcConfig implements WebMvcConfigurer {
    @Autowired
    Consts consts;
    @Bean
    ModelMapper modelmapper(){
        return new ModelMapper();
    }

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/upload/avatar/**")
                .addResourceLocations("file:///"+consts.getUploadDir()+"/avatar/");
    }
}
